package com.example.easypan.mapper;



import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.easypan.pojo.FileInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 小汤
* @description 针对表【file_info(文件信息)】的数据库操作Mapper
* @createDate 2025-02-05 16:53:55
* @Entity com.example.easypan.pojo.FileInfo
*/
@Mapper
public interface FileInfoMapper extends BaseMapper<FileInfo> {

//    @Select("SELECT * FROM file_info " +
//            "WHERE (folder_id = #{pageFolderId} AND folder_type != 1) " +
//            "OR folder_pid = #{pageFolderId} " +
//            "ORDER BY folder_type DESC, file_category ASC, create_time DESC " +
//            "LIMIT #{pageNum}, #{pageSize}")
//    List<FileInfo> selectPage(@Param("pageNum") Integer pageNum,
//                              @Param("pageSize") Integer pageSize,
//                              @Param("pageFolderId") Integer pageFolderId);

    @Select("SELECT * FROM file_info " +
            "WHERE del_flag = 2 " +  // 先筛选出 del_flag = 2 的记录
            "AND ((folder_id = #{pageFolderId} AND folder_type != 1) " +
            "OR folder_pid = #{pageFolderId}) " +
            "ORDER BY folder_type DESC, file_category ASC, create_time DESC " +
            "LIMIT #{pageNum}, #{pageSize}")
    List<FileInfo> selectPage(@Param("pageNum") Integer pageNum,
                              @Param("pageSize") Integer pageSize,
                              @Param("pageFolderId") Integer pageFolderId);




    @Select("select count(*) from file_info WHERE del_flag = 2")
    Integer getCount();


}
